Produced by Araxis Merge on 2023-07-12 04:42:38 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto v4.0.5/Theme Files/Porto Theme/app/code/Smartwave/Dailydeals/Model/Dailydeal/Source | SwDealProduct.php | 2018-10-30 13:43:44 +0000 |
| 2 | Porto v4.0.6/Theme Files/Porto Theme/app/code/Smartwave/Dailydeals/Model/Dailydeal/Source | SwDealProduct.php | 2023-06-12 03:33:37 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 274 |
| Changed | 1 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | <?php | 1 | <?php | |||
| 2 | namespace Smartwave\Dailydeals\Model\Dailydeal\Source; | 2 | namespace Smartwave\Dailydeals\Model\Dailydeal\Source; | |||
| 3 | 3 | |||||
| 4 | class SwDealProduct implements \Magento\Framework\Option\ArrayInterface | 4 | class SwDealProduct implements \Magento\Framework\Option\ArrayInterface | |||
| 5 | { | 5 | { | |||
| 6 | const FIXED = 1; | 6 | const FIXED = 1; | |||
| 7 | const PERCENTAGE = 2; | 7 | const PERCENTAGE = 2; | |||
| 8 | 8 | |||||
| 9 | /** | 9 | /** | |||
| 10 | * to option array | 10 | * to option array | |||
| 11 | * | 11 | * | |||
| 12 | * @return array | 12 | * @return array | |||
| 13 | */ | 13 | */ | |||
| 14 | protected $productFactory; | 14 | protected $productFactory; | |||
| 15 | 15 | |||||
| 16 | 16 | |||||
| 17 | 17 | |||||
| 18 | public function __construct( | 18 | public function __construct( | |||
| 19 | \Magento\Catalog\Model\ProductFactory $productFactory | 19 | \Magento\Catalog\Model\ProductFactory $productFactory | |||
| 20 | ) { | 20 | ) { | |||
| 21 | 21 | |||||
| 22 | $this->productFactory=$productFactory; | 22 | $this->productFactory=$productFactory; | |||
| 23 | } | 23 | } | |||
| 24 | 24 | |||||
| 25 | 25 | |||||
| 26 | public function toOptionArray() | 26 | public function toOptionArray() | |||
| 27 | { | 27 | { | |||
| 28 | 28 | |||||
| 29 | // $childArray=[]; | |||||
| 30 | // Temporary fix | |||||
| 31 | $childArray=[0]; | 29 | $childArray=[0]; | |||
| 32 | 30 | |||||
| 33 | $productcollection=$this->productFactory->create()->getCollection(); | 31 | $productcollection=$this->productFactory->create()->getCollection(); | |||
| 34 | $productcollection->addAttributeToSelect('*'); | 32 | $productcollection->addAttributeToSelect('*'); | |||
| 35 | 33 | |||||
| 36 | foreach ($productcollection as $_product) { | 34 | foreach ($productcollection as $_product) { | |||
| 37 | if ($_product->getTypeId() == "bundle") { | 35 | if ($_product->getTypeId() == "bundle") { | |||
| 38 | $product = $this->productFactory->create()->load($_product->getId()); | 36 | $product = $this->productFactory->create()->load($_product->getId()); | |||
| 39 | //get all the selection products used in bundle product. | 37 | //get all the selection products used in bundle product. | |||
| 40 | $selectionCollection = $product->getTypeInstance(true) | 38 | $selectionCollection = $product->getTypeInstance(true) | |||
| 41 | ->getSelectionsCollection( | 39 | ->getSelectionsCollection( | |||
| 42 | $product->getTypeInstance(true)->getOptionsIds($product), | 40 | $product->getTypeInstance(true)->getOptionsIds($product), | |||
| 43 | $product | 41 | $product | |||
| 44 | ); | 42 | ); | |||
| 45 | 43 | |||||
| 46 | 44 | |||||
| 47 | foreach ($selectionCollection as $proselection) { | 45 | foreach ($selectionCollection as $proselection) { | |||
| 48 | array_push($childArray, $proselection->getProductId()); | 46 | array_push($childArray, $proselection->getProductId()); | |||
| 49 | } | 47 | } | |||
| 50 | } | 48 | } | |||
| 51 | } | 49 | } | |||
| 52 | 50 | |||||
| 53 | 51 | |||||
| 54 | $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | 52 | $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | |||
| 55 | $currencySymbol=$objectManager->create('Magento\Store\Model\StoreManagerInterface'); | 53 | $currencySymbol=$objectManager->create('Magento\Store\Model\StoreManagerInterface'); | |||
| 56 | $currencysymbol=$currencySymbol->getStore()->getCurrentCurrency()->getCurrencySymbol(); | 54 | $currencysymbol=$currencySymbol->getStore()->getCurrentCurrency()->getCurrencySymbol(); | |||
| 57 | 55 | |||||
| 58 | $productcollection=$this->productFactory->create()->getCollection(); | 56 | $productcollection=$this->productFactory->create()->getCollection(); | |||
| 59 | 57 | |||||
| 60 | $productcollection->addAttributeToSelect('*'); | 58 | $productcollection->addAttributeToSelect('*'); | |||
| 61 | $productcollection->addAttributeToFilter('entity_id', ['nin'=>$childArray]); | 59 | $productcollection->addAttributeToFilter('entity_id', ['nin'=>$childArray]); | |||
| 62 | 60 | |||||
| 63 | $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | 61 | $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); | |||
| 64 | 62 | |||||
| 65 | $options = ['value'=>'','label'=>'-- Select Product --']; | 63 | $options = ['value'=>'','label'=>'-- Select Product --']; | |||
| 66 | foreach ($productcollection as $product) { | 64 | foreach ($productcollection as $product) { | |||
| 67 | $productId = $product->getId(); //this is child product id | 65 | $productId = $product->getId(); //this is child product id | |||
| 68 | 66 | |||||
| 69 | $getproduct = $objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($productId); | 67 | $getproduct = $objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($productId); | |||
| 70 | 68 | |||||
| 71 | if (isset($getproduct[0])) { | 69 | if (isset($getproduct[0])) { | |||
| 72 | $productcollection1=$this->productFactory->create()->getCollection(); | 70 | $productcollection1=$this->productFactory->create()->getCollection(); | |||
| 73 | 71 | |||||
| 74 | $productcollection1->addFieldToSelect('*'); | 72 | $productcollection1->addFieldToSelect('*'); | |||
| 75 | 73 | |||||
| 76 | $productcollection1->addFieldToFilter('entity_id', ['eq'=>$getproduct[0]]); | 74 | $productcollection1->addFieldToFilter('entity_id', ['eq'=>$getproduct[0]]); | |||
| 77 | 75 | |||||
| 78 | $sku=$productcollection1->getFirstItem()->getSku(); | 76 | $sku=$productcollection1->getFirstItem()->getSku(); | |||
| 79 | $name=$productcollection1->getFirstItem()->getName() ; | 77 | $name=$productcollection1->getFirstItem()->getName() ; | |||
| 80 | $price=$product->getFinalPrice(); | 78 | $price=$product->getFinalPrice(); | |||
| 81 | $id=$productcollection1->getFirstItem()->getId(); | 79 | $id=$productcollection1->getFirstItem()->getId(); | |||
| 82 | } else { | 80 | } else { | |||
| 83 | if ($product->getTypeId() == "bundle") { | 81 | if ($product->getTypeId() == "bundle") { | |||
| 84 | $bundleprice=[]; | 82 | $bundleprice=[]; | |||
| 85 | 83 | |||||
| 86 | $sku=$product->getSku(); | 84 | $sku=$product->getSku(); | |||
| 87 | $name=$product->getName(); | 85 | $name=$product->getName(); | |||
| 88 | $id=$product->getId(); | 86 | $id=$product->getId(); | |||
| 89 | 87 | |||||
| 90 | 88 | |||||
| 91 | $bundleproduct = $this->productFactory->create()->load($product->getId()); | 89 | $bundleproduct = $this->productFactory->create()->load($product->getId()); | |||
| 92 | //get all the selection products used in bundle product. | 90 | //get all the selection products used in bundle product. | |||
| 93 | $selectionCollection = $bundleproduct->getTypeInstance(true) | 91 | $selectionCollection = $bundleproduct->getTypeInstance(true) | |||
| 94 | ->getSelectionsCollection( | 92 | ->getSelectionsCollection( | |||
| 95 | $bundleproduct->getTypeInstance(true)->getOptionsIds($bundleproduct), | 93 | $bundleproduct->getTypeInstance(true)->getOptionsIds($bundleproduct), | |||
| 96 | $bundleproduct | 94 | $bundleproduct | |||
| 97 | ); | 95 | ); | |||
| 98 | 96 | |||||
| 99 | 97 | |||||
| 100 | foreach ($selectionCollection as $proselection) { | 98 | foreach ($selectionCollection as $proselection) { | |||
| 101 | array_push($bundleprice, $proselection->getFinalPrice()); | 99 | array_push($bundleprice, $proselection->getFinalPrice()); | |||
| 102 | } | 100 | } | |||
| 103 | 101 | |||||
| 104 | $price=min($bundleprice); | 102 | $price=min($bundleprice); | |||
| 105 | } elseif ($product->getTypeId() == "grouped") { | 103 | } elseif ($product->getTypeId() == "grouped") { | |||
| 106 | $groupedprice=[]; | 104 | $groupedprice=[]; | |||
| 107 | 105 | |||||
| 108 | $groupedproduct = $this->productFactory->create()->load($product->getId()); | 106 | $groupedproduct = $this->productFactory->create()->load($product->getId()); | |||
| 109 | $associatedProducts =$groupedproduct->getTypeInstance()->getAssociatedProducts($groupedproduct); | 107 | $associatedProducts =$groupedproduct->getTypeInstance()->getAssociatedProducts($groupedproduct); | |||
| 110 | foreach ($associatedProducts as $_item) { | 108 | foreach ($associatedProducts as $_item) { | |||
| 111 | array_push($groupedprice, $_item->getFinalPrice()); | 109 | array_push($groupedprice, $_item->getFinalPrice()); | |||
| 112 | } | 110 | } | |||
| 113 | 111 | |||||
| 114 | 112 | |||||
| 115 | $sku=$product->getSku(); | 113 | $sku=$product->getSku(); | |||
| 116 | $name=$product->getName(); | 114 | $name=$product->getName(); | |||
| 117 | $id=$product->getId(); | 115 | $id=$product->getId(); | |||
| 118 | $price=min($groupedprice); | 116 | $price=min($groupedprice); | |||
| 119 | } elseif ($product->getvisibility() !=1) { | 117 | } elseif ($product->getvisibility() !=1) { | |||
| 120 | $sku=$product->getSku(); | 118 | $sku=$product->getSku(); | |||
| 121 | $name=$product->getName(); | 119 | $name=$product->getName(); | |||
| 122 | $id=$product->getId(); | 120 | $id=$product->getId(); | |||
| 123 | $price=$product->getFinalPrice(); | 121 | $price=$product->getFinalPrice(); | |||
| 124 | } | 122 | } | |||
| 125 | } | 123 | } | |||
| 126 | 124 | |||||
| 127 | 125 | |||||
| 128 | if ($price != 0) { | 126 | if ($price != 0) { | |||
| 129 | $options[] = | 127 | $options[] = | |||
| 130 | [ 'value'=>$sku, | 128 | [ 'value'=>$sku, | |||
| 131 | 'label'=>"ID:".$id." ".$name."- ".$currencysymbol."".round($price, 2)." " | 129 | 'label'=>"ID:".$id." ".$name."- ".$currencysymbol."".round($price, 2)." " | |||
| 132 | ]; | 130 | ]; | |||
| 133 | } | 131 | } | |||
| 134 | } | 132 | } | |||
| 135 | 133 | |||||
| 136 | $unique = array_map("unserialize", array_unique(array_map("serialize", $options))); | 134 | $unique = array_map("unserialize", array_unique(array_map("serialize", $options))); | |||
| 137 | 135 | |||||
| 138 | return $unique; | 136 | return $unique; | |||
| 139 | } | 137 | } | |||
| 140 | } | 138 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.